<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of login_modal
 *
 * @author zwang
 */
class login_model extends CI_Model {

    //put your code here
    function validate($username, $password){
//        $username = "myra";
        $sql = "SELECT password FROM user WHERE username='$username' LIMIT 1";
        $query = $this->db->query($sql);
        if($query->num_rows() == 0){
            return "Username not exists.";
        }
        else{
            $password_md5 = md5($password);
            if($password_md5 == $query->row()->password){
                return "SUCCESS";
            }
            else{
                return "Password incorrect";
            }
        }
    }
}

?>
